<?php
namespace App\Controllers\Index;
use App\Models\Peizhi\Peizhi;

/**
*	首页后台接口配置
*/
class SetPeizhi extends \App\Libs\Base\BaseAction
{
    protected function beforeRun() {
        parent::beforeRun();
        //$this->needLogin = TRUE;
    }
	
	public function execute(){
		$type = $this->request->get('type');
		$data = $this->request->get('data');
		
		if( empty($type) ){
				return \App\Libs\Views\Json::view(1, '请输入相关参数', '');	
		}
		if( empty( $data ) ){
				return \App\Libs\Views\Json::view(1, '请输入相关数据', '');		
		}
		
		$peizhi = Peizhi::find("type={$type}");
		$peizhi->data = $data;
		
		$result = $peizhi->save();
		
		
		if( $result == false ){
			return \App\Libs\Views\Json::view(1, '失败', '');	
		}
		return \App\Libs\Views\Json::view(0, '成功', null);	
	}
}
